/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef COMSTACK_TYPES_H
#define COMSTACK_TYPES_H

#include "Std_Types.h" /* standard AUTOSAR types */
#include "comstack_cfg.h"

/* Version Info Begin */
#define COMSTACK_TYPES_H_VENDOR_ID 0x8C
#define COMSTACK_TYPES_H_AR_RELEASE_MAJOR_VERSION 4
#define COMSTACK_TYPES_H_AR_RELEASE_MINOR_VERSION 3
#define COMSTACK_TYPES_H_AR_RELEASE_REVISION_VERSION 1
#define COMSTACK_TYPES_H_SW_MAJOR_VERSION 1
#define COMSTACK_TYPES_H_SW_MINOR_VERSION 0
#define COMSTACK_TYPES_H_SW_PATCH_VERSION 0
/* Version Info End */

/* The Icom configuration ID */
typedef uint8 IcomConfigIdType;

/* Used to store the identifier of a partial network cluster. */
typedef uint8 PNCHandleType;

/* Variables of this type shall be used to return the bus status
   evaluated by a transceiver. */
typedef uint8 BusTrcvErrorType;
#define BUSTRCV_OK ((BusTrcvErrorType)0x00u)
#define BUSTRCV_E_ERROR ((BusTrcvErrorType)0x01u)

/* The type for errors which can occur when activating or
deactivating Pretended Networking. */
typedef enum { ICOM_SWITCH_E_OK, ICOM_SWITCH_E_FAILED } IcomSwitch_ErrorType;

/* Basic information about a PDU of any type */
typedef struct {
    uint8 *SduDataPtr;
    PduLengthType SduLength;
} PduInfoType;

typedef enum {
    TP_STMIN = 0,
    TP_BS,
    TP_BC,
} TPParameterType;

typedef enum {
    TP_DATACONF,
    TP_DATARETRY,
    TP_CONFPENDING,
    TP_NORETRY,
} TpDataStateType;

typedef struct {
    TpDataStateType TpDataState;
    PduLengthType TxTpDataCnt;
} RetryInfoType;

/* Variables of this type shall be used to store the result of a buffer request. */
typedef enum {
    BUFREQ_OK,
    BUFREQ_E_NOT_OK,
    BUFREQ_E_BUSY,
    BUFREQ_E_OVFL
} BufReq_ReturnType;

#define BUSTRCV_NO_ERROR 0x00
#define BUSBUSTRCV_E_ERROR 0x01

typedef uint8 NetworkHandleType;

#endif /* COMSTACK_TYPES_H */
